//
//  DetailTeamViewController.m
//  LOL_JewelBox
//
//  Created by dllo on 15/4/28.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "DetailTeamViewController.h"
#import "UIImageView+WebCache.h"
#import "ToolsView.h"
#import "TeamModel.h"
#import "TeamHeroViewController.h"
@interface DetailTeamViewController ()

@property(nonatomic, retain)ToolsView *toolsView;
@property(nonatomic, retain)UIScrollView *scrollView;
@property(nonatomic, retain)UILabel *detailTitle;// 标题
@property(nonatomic, retain)UIImageView *hero1;  // 英雄一
@property(nonatomic, retain)UIImageView *hero2;  // 英雄二
@property(nonatomic, retain)UIImageView *hero3;  // 英雄三
@property(nonatomic, retain)UIImageView *hero4;  // 英雄四
@property(nonatomic, retain)UIImageView *hero5;  // 英雄五
@property(nonatomic, retain)UILabel *des;        // 标题简介
@property(nonatomic, retain)UILabel *des1;       // 英雄一简介
@property(nonatomic, retain)UILabel *des2;       // 英雄二简介
@property(nonatomic, retain)UILabel *des3;       // 英雄三简介
@property(nonatomic, retain)UILabel *des4;       // 英雄四简介
@property(nonatomic, retain)UILabel *des5;       // 英雄五简介

@end

@implementation DetailTeamViewController

- (void)dealloc
{
    
    [_toolsView release];
    [_detailTitle release];
    [_hero1 release];
    [_hero2 release];
    [_hero3 release];
    [_hero4 release];
    [_hero5 release];
    [_des release];
    [super dealloc];
    
}

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = @"详情";
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    // 铺设自定义View
    self.toolsView = [[ToolsView alloc] initWithFrame:CGRectMake(0, 0, VIEWWIDTH, VIEWHEIGHT)];
    [self.view addSubview:self.toolsView];
    self.toolsView.backgroundColor = [UIColor colorWithRed:218 / 255.0 green:218 / 255.0 blue:218 / 255.0 alpha:1];
    [_toolsView release];
    
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, VIEWWIDTH, VIEWHEIGHT)];
    self.scrollView.contentSize = CGSizeMake(VIEWWIDTH, VIEWHEIGHT + 250);
    [self.toolsView addSubview:self.scrollView];
    self.scrollView.backgroundColor = [UIColor colorWithRed:230 / 255.0 green:230 / 255.0 blue:230 / 255.0 alpha:1];
    [_scrollView release];

    
    // 设置阵容英雄详情跳转按钮
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"阵容英雄详情" style:UIBarButtonItemStylePlain target:self action:@selector(rightButtonClick:)];
    
    [self createView];
}

// 跳转方法
- (void)rightButtonClick:(id)sander
{
    TeamHeroViewController *teamHero = [[TeamHeroViewController alloc]init];
    teamHero.teamsHero1 = self.teamHero1;
    teamHero.teamsHero2 = self.teamHero2;
    teamHero.teamsHero3 = self.teamHero3;
    teamHero.teamsHero4 = self.teamHero4;
    teamHero.teamsHero5 = self.teamHero5;
    teamHero.teamsDes1 = self.teamDes1;
    teamHero.teamsDes2 = self.teamDes2;
    teamHero.teamsDes3 = self.teamDes3;
    teamHero.teamsDes4 = self.teamDes4;
    teamHero.teamsDes5 = self.teamDes5;
    
    
    [self.navigationController pushViewController:teamHero animated:YES];
}

// 详情
- (void)createView
{
    
    self.detailTitle = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, VIEWWIDTH - 20, 60)];
    self.detailTitle.text = self.teamTitle;
    [self.scrollView addSubview:self.detailTitle];
    self.detailTitle.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
    self.detailTitle.numberOfLines = 0;
    self.detailTitle.lineBreakMode = NSLineBreakByCharWrapping;
    [self.detailTitle sizeToFit];
    [_detailTitle release];
    
    
    self.hero1 = [[UIImageView alloc] initWithFrame:CGRectMake(10 , 70, (VIEWWIDTH - 60) / 5, (VIEWWIDTH - 60) / 5)];
    
    NSString *str1 = [NSString stringWithFormat:@"http://img.lolbox.duowan.com/champions/%@_120x120.jpg", self.teamHero1];
    NSURL *url1 = [NSURL URLWithString:str1];
    [self.hero1 sd_setImageWithURL:url1];
    [self.scrollView addSubview:self.hero1];
    [_hero1 release];
    
    self.hero2 = [[UIImageView alloc] initWithFrame:CGRectMake((VIEWWIDTH - 60)  / 5 + 20, 70, (VIEWWIDTH - 60) / 5, (VIEWWIDTH - 60) / 5)];
    NSString *str2 = [NSString stringWithFormat:@"http://img.lolbox.duowan.com/champions/%@_120x120.jpg", self.teamHero2];
    NSURL *url2 = [NSURL URLWithString:str2];
    [self.hero2 sd_setImageWithURL:url2];
    [self.scrollView addSubview:self.hero2];
    [_hero2 release];
    
    self.hero3 = [[UIImageView alloc] initWithFrame:CGRectMake((VIEWWIDTH - 60) * 2 / 5 + 30, 70, (VIEWWIDTH - 60) / 5, (VIEWWIDTH - 60) / 5)];
    NSString *str3 = [NSString stringWithFormat:@"http://img.lolbox.duowan.com/champions/%@_120x120.jpg", self.teamHero3];
    NSURL *url3 = [NSURL URLWithString:str3];
    [self.hero3 sd_setImageWithURL:url3];
    [self.scrollView addSubview:self.hero3];
    [_hero3 release];
    
    self.hero4 = [[UIImageView alloc] initWithFrame:CGRectMake((VIEWWIDTH - 60) * 3 / 5 + 40, 70, (VIEWWIDTH - 60) / 5, (VIEWWIDTH - 60) / 5)];
    NSString *str4 = [NSString stringWithFormat:@"http://img.lolbox.duowan.com/champions/%@_120x120.jpg", self.teamHero4];
    NSURL *url4 = [NSURL URLWithString:str4];
    [self.hero4 sd_setImageWithURL:url4];
    [self.scrollView addSubview:self.hero4];
    [_hero4 release];
    
    self.hero5 = [[UIImageView alloc] initWithFrame:CGRectMake((VIEWWIDTH - 60) * 4 / 5 + 50, 70, (VIEWWIDTH - 60) / 5, (VIEWWIDTH - 60) / 5)];
    NSString *str5 = [NSString stringWithFormat:@"http://img.lolbox.duowan.com/champions/%@_120x120.jpg", self.teamHero5];
    NSURL *url5 = [NSURL URLWithString:str5];
    [self.hero5 sd_setImageWithURL:url5];
    [self.scrollView addSubview:self.hero5];
    [_hero5 release];
    
    self.des = [[UILabel alloc] initWithFrame:CGRectMake(10, 153, VIEWWIDTH - 20, 305)];
    self.des.text = self.teamDes;
    [self.scrollView addSubview:self.des];
    self.des.font = [UIFont systemFontOfSize:16];
    self.des.numberOfLines = 0;
    self.des.lineBreakMode = NSLineBreakByCharWrapping;
    [self.des sizeToFit];
    [_des release];
    
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
